<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/rp/common/taglib.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <base href="<%=basePath%>">
    
    <title>用户注册</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	
	<script src="rp/scripts/boot.js" type="text/javascript"></script>
	
	<style type="text/css">
	   	
    </style>
	
  </head>
  
  <body class="body-p5" style="margin: 20px;">
  	
  	<form id="rForm">
  		<table>
  			<tr>
  				<td>
  					<label>用户名：</label>
  				</td>
  				<td>
  					<input id="username" name="username" class="mini-textbox" width="250" required="true"
  						emptyText="请使用英文字母，建议使用手机或邮箱" />
  				</td>
  			</tr>
  			<tr>
  				<td valign="top">
  					<label>密码：</label>
  				</td>
  				<td>
  					<input id="password" name="password" class="mini-password" width="250" required="true"/>
  					<br/>
  					<span>至少6位，必须是字母或特殊符号和数字结合</span>
  				</td>
  			</tr>
  			<tr>
  				<td>
  					<label>密码确认：</label>
  				</td>
  				<td>
  					<input id="password2" class="mini-password" width="250" required="true"/>
  				</td>
  			</tr>
  			<tr>
  				<td>
  					<label>姓名：</label>
  				</td>
  				<td>
  					<input id="realname" name="realname" class="mini-textbox" width="200" required="true" />
  				</td>
  			</tr>
  			<tr>
  				<td>
  					<label>部门：</label>
  				</td>
  				<td>
    				<input class="mini-treeselect" url="rp/system/organMng/getOrgans" 
    					multiSelect="false" valueFromSelect="false"
				        name="organId" textField="name" valueField="id" parentField="pid" allowInput="false"
				        popupHeight="160" emptyText="选择所属部门"/>
  				</td>
  			</tr>
  			<tr>
  				<td valign="top">
  					<label>备注：</label>
  				</td>
  				<td>
  					<textarea name="remark" class="mini-textarea" width="250" height="150" emptyText=""></textarea>
  				</td>
  			</tr>
  			<tr>
  				<td></td>
  				<td>
  					<a class="mini-button" onclick="submitForm()"><i class="fa fa-floppy-o fa-lg"></i> 提交</a>
  				</td>
  			</tr>
  		</table>
  		
  	</form>
  	
	<script type="text/javascript">
		var rForm;
	
		$(function(){
			mini.parse();
			rForm = new mini.Form("rForm");
		});
		
		function submitForm(){
			rForm.validate();
            if (rForm.isValid() == false) return;
            
            var password = mini.get("password").getValue();
            var password2 = mini.get("password2").getValue();
            
            if(password != password2){
            	mini.alert("两次输入密码不相同，请重新确认输入");
            	return;
            }
            
          	//提交表单数据            
            var data = rForm.getData();      //获取表单多个控件的数据
            var json = rp_encode(data);   //序列化成JSON
            
            rp_ajax("rp/registerUser", {json:json}, function(result){
            	if(result == "success"){
            		rForm.clear();
            		mini.alert("注册成功，请耐心等待管理员审核");
            	}else{
            		mini.alert(result);
            	}
            });
		}
	</script>
  </body>
</html>
